<style scoped>
.el-row{
  height: 100%;
}

.el-menu{
  border-right:none;
}
.el-aside{
  border-right: 1px solid #f5f1f1;
}
.item{
	min-height: 30rpx;
}
</style>

<template>
  <el-aside width="200px">
    <el-row class="tac">
      <el-col>
        <el-menu
          default-active="home"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
        >
		  <template v-for="(item, index) in routerArr">
			<el-menu-item :index="item.index" @click="goPage(item.url)" :key="index" class="item">
				<i :class="item.icon"></i>
				<span slot="title">{{item.name}}</span>
			</el-menu-item>
		  </template>
        </el-menu>
      </el-col>
    </el-row>
  </el-aside>
</template>

<script>
var $this = {};
export default {
  data() {
    return {
		routerArr: [
			{icon: "el-icon-office-building", index: "home", name: "首页", url: "/home"},
			{icon: "el-icon-user", index: "user", name: "用户管理", url: "/user"},
			{icon: "el-icon-reading", index: "bicycle", name: "自行车管理", url: "/bicycle"},
			{icon: "el-icon-bicycle", index: "post", name: "论坛管理", url: "/post"},
			{icon: "el-icon-chat-line-square", index: "knowledge", name: "知识管理", url: "/knowledge"},
		]
	};
  },
  beforeCreate() {
    $this = this;
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },

    //跳转到某个导航页
    goPage(link) {
     $this.$router.push(link)
    }
  }
};
</script>